<?php
if ( is_array( $contacts ) and ( count( $contacts ) > 0 )) {
    echo '<table class="contact_list">'."\n"; 
    // echo '<tr>'."\n";
    // echo "\t".'<th></th>'."\n";
    // echo "\t".'<th>First Name</th>'."\n";
    // echo "\t".'<th>Last Name</th>'."\n";
    // echo "\t".'<th>Email</th>'."\n";
    // echo "\t".'<th></th>'."\n";
    // echo '</tr>'."\n";
    foreach ( $contacts as $c ) {
        $address = $c[ 'fname' ].' '.$c[ 'lname' ].' <'.$c[ 'email' ].'>';
        echo '<tr>'."\n";
        echo "\t".'<td>';
        echo '<span class="toggle_not_selected" onClick="toggle( 0, \''.$address.'\', '.$c[ 'rowid' ].' );" id="0_'.$c[ 'rowid' ].'">To</span>';
        echo '<span class="toggle_not_selected" onClick="toggle( 1, \''.$address.'\', '.$c[ 'rowid' ].' );" id="1_'.$c[ 'rowid' ].'">CC</span>';
        echo '<span class="toggle_not_selected" onClick="toggle( 2, \''.$address.'\', '.$c[ 'rowid' ].' );" id="2_'.$c[ 'rowid' ].'">BCC</span>';
        echo '</td>'."\n";
        echo "\t".'<td>'.$c[ 'fname' ].'</td>'."\n";
        echo "\t".'<td>'.$c[ 'lname' ].'</td>'."\n";
        echo "\t".'<td><a href="mailto:'.$address.'">'.$c[ 'email' ].'</a></td>'."\n";
        echo "\t".'<td style="font-size: 85%;"><a class="edit_hidden" href="edit.php?id='.$c[ 'rowid' ].'">edit</a></td>'."\n";
        echo '</tr>'."\n";
    }
    echo '</table>'."\n";
} else {
    echo '<div class="hint">';
    echo 'No contacts found.';
    echo '</div>'."\n";
}
?>
